package com.aaa.appUtil.util;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * fileName:Scheduledtask
 * description:
 * author:zxh
 * createTime:2020/1/9 20:09
 * version:1.0.0
 */
@Component
public class Scheduledtask {
    @Async  //使其不在一个线程中
    @Scheduled(initialDelay = 1000,fixedDelay = 1000)
    public void task(){
        System.out.println("initialDelay延迟多少毫秒后执行"+"..........."+"fixedDelay执行完多少毫秒之后执行");
    }
    @Async
    @Scheduled(fixedRate = 2000)
    public void taskFixedRate(){
        System.out.println("延迟1000毫秒后执行，之后每多少毫秒执行一次");
    }
    @Async
    @Scheduled(cron = "* */5 * * * ?")
    public void taskCron(){
        System.out.println("每两秒执行一次");
    }
}
